class afs::config inherits afs {
  # config /etc/sysconfig/afs of openafs file
  case $operatingsystemmajrelease {
   '8','9': {
      file { "/usr/vice/etc/CellServDB.dist":
        owner   => root,
        group   => root,
        mode    => '0644',
        content => template("afs/cellservdb-alma9.erb"),
      }
      file { "/usr/vice/etc/CellServDB":
        owner   => root,
        group   => root,
        mode    => '0644',
        content => template("afs/cellservdb-alma9.erb"),
      }
      file {"/usr/vice/etc/cacheinfo":
              owner   => root,
              group   => root,
              mode    => '0644',
              content => template("afs/cacheinfo.erb"),
      }
   }
   '5': {
     augeas{"AFSCACHESIZE" :
      context => "/files/etc/sysconfig/afs/",
      changes => 'set CACHESIZE \'"AUTOMATIC"\'',
     }
     augeas{"AFSCACHEDIR" :
      context => "/files/etc/sysconfig/afs/",
      changes => 'set CACHEDIR "/var/cache/openafs"',
      require => Package["openafs-client"],
     }
     augeas{"AFSOPTIONS" :
      context => "/files/etc/sysconfig/afs/",
      changes => 'set OPTIONS \'"-chunksize 19 -daemons 6 -dcache 15000 -fakestat  -files 50000 -stat 15000 -volumes 256"\'',
     }
   }
   '6': {
    file {"/etc/sysconfig/afs":
      owner   => root,
      group   => root,
      mode    => '0755',
      content => template("afs/afs6.erb"),
    }
    }
  '7':{
    case $operatingsystem {
    /centos|CentOS/: {
 
    #file {"/etc/pam.d/password-auth-ac":
    #        owner   => root,
    #        group   => root,
    #        mode    => '0644',
    #        source  => "puppet:///modules/afs/password-auth-ac-7"
    #}
    #file {"/etc/pam.d/system-auth-ac":
    #        owner   => root,
    #        group   => root,
    #        mode    => '0644',
    #        source  => "puppet:///modules/afs/system-auth-ac-7"
    #}
      file {"/etc/sysconfig/openafs":
              owner   => root,
              group   => root,
              mode    => '0755',
              content => template("afs/afs-centos.erb"),
      }
      file {"/usr/vice/etc/cacheinfo":
              owner   => root,
              group   => root,
              mode    => '0644',
              content => template("afs/cacheinfo.erb"),
      }

    } # end centos
    /scientific|Scientific/: {
      file {"/etc/sysconfig/afs":
              owner   => root,
              group   => root,
              mode    => '0755',
              content => template("afs/afs6.erb"),
      }
    } # end scientific
    } # end case $operatingsystem
    file { "/usr/vice/etc/CellServDB.dist":
      owner   => root,
      group   => root,
      mode    => '0644',
      content => template("afs/cellservdb-alma9.erb"),
    }
    file { "/usr/vice/etc/CellServDB":
      owner   => root,
      group   => root,
      mode    => '0644',
      content => template("afs/cellservdb-alma9.erb"),
    }

    }
  }
  file { "/usr/vice/etc/ThisCell":
    owner   => root,
    group   => root,
    mode    => '0644',
    content => "ihep.ac.cn",
  }

  case $operatingsystem {
  /centos|CentOS/: {
    exec { 'config afs cache dir':
      command => '/usr/bin/sed -i "s/\/var\/cache\/afs/\/usr\/vice\/cache/g" /etc/fstab',
      timeout => 30,
      onlyif  => '/usr/bin/grep "/var/cache/afs" /etc/fstab',
    }
    }
  }
}
